<!--
 * @Date: 2023-05-08 14:07:49
 * @LastEditTime: 2023-05-10 10:41:13
-->
<template>
  <a-modal v-model="visible" title="语言排序" :footer="null" :destroyOnClose="true" @cancel="visible = false">
    <draggable v-model="sortArr" @start="drag = true" @end="drag = false">
      <Tag
        v-for="item in sortArr"
        :tag="item"
        :closable="false"
        :key="item.language_id"
        :labelName="{ label: 'language_name' }"
      />
    </draggable>

    <div class="btn_box">
      <a-button @click="handleChange" class="edit_btn">确定</a-button>
    </div>
  </a-modal>
</template>

<script>
import draggable from 'vuedraggable'
import Tag from '../Tag'

export default {
  name: 'Sort',

  components: { draggable, Tag },

  data () {
    return {
      visible: false,
      drag: false,
      sortArr: []
    }
  },

  mounted () {},

  methods: {
    handleChange () {
      this.visible = false
      this.$emit('change', this.sortArr)
    }
  }
}
</script>

<style lang="less" scoped>
.ant-tag {
  padding: 5px 10px;
  box-sizing: border-box;
  position: relative;
  margin-bottom: 8px;
}

.btn_box {
  width: 100%;
  height: fit-content;
  text-align: center;
}
</style>
